package com.cp.provider;

import com.cp.commons.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.sound.midi.Soundbank;
import java.util.ArrayList;
import java.util.List;

/**
 * @author feipeng
 * @site www.gcp168.cn
 * @create 2020-08-24 22:03
 */
@RestController
public class UserController {
    @GetMapping("/user/{ids}")//假设consumer传过来的多个id
    public List<User> getUserByIds(@PathVariable String ids){
        System.out.println(ids);
        String[] split = ids.split(",");
        List<User> users = new ArrayList<>();
        for(String s : split){
            User u = new User();
            u.setId(Integer.parseInt(s));
            users.add(u);
        }
        return users;

    }
}
